package com.miracle9.game.dao;

import com.miracle9.game.entity.Admin;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

@Repository
public class AdminServiceDao extends SqlOperating<Admin, Integer> {

    @Cacheable(value = {"springCache"}, key = "'adminList'")
    public List<Admin> getAdminsByType() {
        return q_CreateSqlList("from Admin where type!=0 and type!=4", new Object[0]);
    }

    @CacheEvict(value = {"springCache"}, key = "'adminList'")
    public Integer saveReturnInteger(Admin admin) {
        return (Integer) saveReturn(admin);
    }

    @CacheEvict(value = {"springCache"}, key = "'adminList'")
    public void deleteById(int id) {
        deleteById(Integer.valueOf(id));
    }

    @CacheEvict(value = {"springCache"}, key = "'adminList'")
    public void updateAdminInfo(Admin admin) {
        update(admin);
    }

}
